#include <xp/bas/list.h>
#include <xp/bas/stdio.h>

#ifdef __linux
#include <mcheck.h>
#endif

xp_ssize_t print_datum (xp_list_t* list, void* datum)
{
	xp_printf (XP_TEXT("%d\n"), *(int*)datum);
	return 1;
}

int xp_main (void)
{

	xp_list_t list;
	int i;

#ifdef __linux
	mtrace ();
#endif

	if (xp_list_open (&list, 5, xp_sizeof(int), XP_NULL) == XP_NULL) {
		xp_printf (XP_TEXT("cannot open a list\n"));
		return -1;
	}

	for (i = 20; i < 30; i++) xp_list_append (&list, &i);
	xp_list_walk (&list, print_datum);

	xp_list_close (&list);
#ifdef __linux
	muntrace ();
#endif
	return 0;
}
